package com.bjpowernode.mvc.convert;


import com.bjpowernode.db.domain.ProductInfo;
import com.bjpowernode.mvc.model.dto.CollectProductDTO;
import com.bjpowernode.mvc.model.vo.ProductVO;
import com.bjpowernode.mvc.model.vo.CollectProductVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface ProductConvert {
    //1、使用@Mappings注解解决,将ProductInfo转换为ProductVO
    //CollectProductDTO  --> CollectProductVO
    CollectProductVO toCollectProductVO(CollectProductDTO dto);

    //2.定义一个辅助方法
    @Mappings({@Mapping(target = "name", source = "productName"),
            @Mapping(target = "type", source = "productType"),
            @Mapping(target = "leftMoney", source = "leftProductMoney"),
            @Mapping(target = "minLimit", source = "bidMinLimit"),
            @Mapping(target = "maxLimit", source = "bidMaxLimit"),
    })
    ProductVO toProductVo(ProductInfo productInfo);


    //3、list集合的转换，CollectProductDTO中的list集合转为CollectProductVO中的list集合
    //List<ProductInfo> --> List<ProductVO>
    List<ProductVO> toProductVOList(List<ProductInfo> productInfoList);
}


